﻿<navigation:Page x:Class="SharpGym.Silverlight.Views.Alunos"
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d"
                 xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
                 xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
                 xmlns:Aluno="clr-namespace:SharpGym.Silverlight.Views.Aluno" d:DesignWidth="640" d:DesignHeight="480"
                 Title="Alunos Page" xmlns:my="clr-namespace:SharpGym.Silverlight.SharpService">
    <navigation:Page.Resources>
        <CollectionViewSource x:Key="alunoDtoViewSource"
                              d:DesignSource="{d:DesignInstance my:AlunoDto, CreateList=True}" />
    </navigation:Page.Resources>
    <Grid x:Name="LayoutRoot">
        <Grid.ColumnDefinitions>
            <ColumnDefinition />
            <ColumnDefinition Width="3*" />
        </Grid.ColumnDefinitions>

        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>

        <ListBox x:Name="AlunosList" ItemsSource="{Binding Source={StaticResource alunoDtoViewSource}}" Margin="10"
                 Grid.RowSpan="2" SelectionMode="Single" SelectionChanged="AlunosList_OnSelectionChanged">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding Nome}" />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>

        <Aluno:EditAluno x:Name="EditAlunoView" Grid.Column="1" Margin="10"
                         DataContext="{Binding ElementName=AlunosList, Path=SelectedItem}" Visibility="Collapsed" />
        <Aluno:ViewAluno x:Name="ViewAlunoView" Grid.Column="1" Margin="10"
                         DataContext="{Binding ElementName=AlunosList, Path=SelectedItem}" Visibility="Collapsed" />
        <Aluno:NewAluno x:Name="NewAlunoView" Grid.Column="1" Margin="10" Visibility="Collapsed" />


        <StackPanel Grid.Column="1" Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,0,10">
            <Button Width="100" Margin="10,0" Click="AddButton_Click">Adicionar</Button>
            <Button Width="100" Margin="10,0" IsEnabled="False" x:Name="EditButton" Click="EditButton_Click">Editar</Button>
            <Button Width="100" Margin="10,0" x:Name="RemoveButton" Click="RemoveButton_Click">Remover</Button>
        </StackPanel>

        <toolkit:BusyIndicator DataContextChanged="Busy_OnDataContextChanged" x:Name="Busy" Grid.ColumnSpan="2"
                               Grid.RowSpan="2" BusyContent="{StaticResource CarregandoAlunosMessage}" />
    </Grid>
</navigation:Page>